const jwt = require('jsonwebtoken');
const config = require('../config/auth.config.js')

const auth = (ctx,next) => {
    // 只负责鉴权
    // ctx.request.header 在请求头带上token
    
    const acthorization = ctx.header.authorization || '';
    console.log(acthorization,'/////////////');
    // ctx.body = acthorization;
    const jsonObj = jwt.verify(acthorization,config.secret)
    ctx.request.uid = jsonObj.uid
    next();
}

module.exports = auth